package homework;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class doudizhu {
	public static void main(String[] args) {

		TreeMap<Integer,String> treeMap = new TreeMap<Integer, String>();
		ArrayList<Integer> key=new ArrayList<>();
		String[] colors={"♠","♣","♦","♥"};
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		treeMap.put(0, "大王");
		key.add(0);
		treeMap.put(1, "小王");
		key.add(1);
		int num=2;
		for(String number:numbers){
			for(String color:colors){
				treeMap.put(num, color+number);
				key.add(num);
				num++;
			}
		}
		
		Collections.shuffle(key);
		player p1=new player();p1.setName("老王");
		player p2=new player();p2.setName("老李");
		player p3=new player();p3.setName("老六");
		ArrayList<Integer> dipai=new ArrayList<Integer>();

		key.stream().forEach(i->{if(i>=51){
							dipai.add(i);
						}else if(i%3==0){
							p1.getPoker().add(i);
						}else if(i%3==1){
							p2.getPoker().add(i);
						}else if(i%3==2){
							p3.getPoker().add(i);
						}});
		Collections.sort(p1.getPoker(),(o1,o2)->o1-o2);
		Collections.sort(p2.getPoker(),(o1,o2)->o1-o2);
		Collections.sort(p3.getPoker(),(o1,o2)->o1-o2);
		System.out.println(p1.getName());
		show(treeMap,p1.getPoker());
		System.out.println(p2.getName());
		show(treeMap,p2.getPoker());
		System.out.println(p3.getName());
		show(treeMap,p3.getPoker());
		System.out.println("底牌：");
		show(treeMap,dipai);
	}
	public static void show(TreeMap<Integer,String> map,ArrayList<Integer> list){
		System.out.println("");
		for(Integer i:list){
			System.out.print(map.get(i));
		}
		System.out.println("");
	}
}
